<?php require_once 'header.php'; ?>
<?php 
session_start();
if (empty($_SESSION['status'])||empty($_SESSION['id'])||empty($_SESSION['name'])) {
  echo "<script>window.location.href='signin.php';</script>";
}
 ?>
<div class="container">
<h1 class="text-center">教务管理系统</h1>

<div class="pull-right">

<?php 
if (!empty($_GET['zhuxiao'])) {
   unset($_SESSION['status']);
   echo "<script>window.location.reload();</script>";
}
 ?>
 <form action="./" method="get">
 <button type="button" class="btn btn-success" data-toggle="modal" data-target=".bs-me-modal-sm"><?php echo $_SESSION['name']; ?></button>
  <input type="hidden" name="zhuxiao" value="zhuxiao">
  <button type="submit" class="btn btn-danger">注销</button>
</form>

<div class="modal fade bs-me-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="gridSystemModalLabel"><?php echo $_SESSION['name']; ?></h4>
        </div>
        <?php 
          require_once 'connect.php';
          $class=$_SESSION['status'];
          $className="";
          switch ($class) {
            case 1:
            $className="administrations";
              break;
            case 2:
            $className="teachers";
             break;
            case 3:
            $className="students";
              break;
            default:
              
              break;
          }
          $query="select * from ".$className." where id=".$_SESSION['id'];
          $result=$mysql->query($query);
          $row=$result->fetch_assoc();

          if ((!empty($_POST['email']))&&(!empty($_POST['password']))){
            $brief=empty($_POST['brief'])?NULL:$_POST['brief'];
            $queryChange="update ".$className." set email='".$_POST['email']."', password='".$_POST['password']."', brief='".$brief."'";
            $resultChange=$mysql->query($queryChange);
            if ($resultChange) {
              echo "<script>alert('修改成功！');window.location.replace(location.href);</script>";

            }else{
              echo "<script>alert('修改失败！')</script>";
            }
          }
         ?>
        <form action="./" method="post">
        <div class="modal-body">

         <!-- <div class="form-group">
            <label for="sex" class="col-sm-2 control-label">性别</label>
            <div class="col-sm-10">
              <label class="radio-inline">
                <input type="radio" name="sex" id="sex" value="m" checked> 男
              </label>
              <label class="radio-inline">
                <input type="radio" name="sex" id="sex" value="w"> 女
              </label>
            </div>
          </div> -->

         <!--  <div class="form-group">
            <label for="age" class="col-sm-2 control-label">年龄</label>
            <div class="col-sm-10">
              <input type="number" class="form-control" id="age" placeholder="请输入年龄" name="age" value="">
            </div>
          </div> -->

         <div class="form-group">
            <label for="inputEmail" class="control-label">邮箱</label>
            <div class="">
               <input type="email" id="inputEmail" class="form-control" placeholder="Email address" name="email" value="<?php echo $row['email']; ?>" required>
            </div>
          </div> 
        
        <div class="form-group">
            <label for="inputPassword" class="control-label">密码</label>
            <div class="">
                <input type="password" id="inputPassword" class="form-control" placeholder="Password" name="password" value="<?php echo $row['password']; ?>" required>
            </div>
          </div> 

          <div class="form-group">
            <label class="control-label">简介</label>
            <div class="">
               <textarea class="form-control" rows="3" name="brief"><?php echo $row['brief']; ?></textarea>
            </div>
          </div> 
        </div>
      <div class="modal-footer">
          <button class="btn btn-primary" type="submit">修改</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        </div>
        </form>
    </div>
  </div>
</div>

</div>



  <?php if ($_SESSION['status']==1) {
    require_once 'administrations.php';
    require_once 'add_lessons.php';
  } 
  if ($_SESSION['status']==2) {
    require_once 'teacher.php';
  } 
  ?>
  <form class="form-inline" action="lessons.php">
      <div class="form-group">
        <select class="form-control input-lg" name="term">
          <option>2014年上学期</option>
          <option>2014年下学期</option>
          <option>2015年上学期</option>
          <option>2015年下学期</option>
        </select>
      </div>
      <button type="submit" class="btn btn-default btn-lg">查看课程信息</button>
  </form>




  <div class="carousel slide" id="carousel-392499">
        <ol class="carousel-indicators">
          <li data-slide-to="0" data-target="#carousel-392499">
          </li>
          <li data-slide-to="1" data-target="#carousel-392499">
          </li>
          <li data-slide-to="2" data-target="#carousel-392499">
          </li>
        </ol>
        <div class="carousel-inner">
          <div class="item active">
            <img alt="" src="img/1.jpg"/>
            <div class="carousel-caption">
              <h2>
                我们在这里等着你！
              </h2>
              <p>
                
              </p>
            </div>
          </div>
          <div class="item">
            <img alt="" src="img/2.jpg" />
            <div class="carousel-caption">
              <h2>
                美丽的校园
              </h2>
              <p>
              </p>
            </div>
          </div>
          <div class="item">
            <img alt="" src="img/3.jpg" />
            <div class="carousel-caption">
              <h2>
                校园一角
              </h2>
              <p>
              
              </p>
            </div>
          </div>
        </div> <a data-slide="prev" href="#carousel-392499" class="left carousel-control">‹</a> <a data-slide="next" href="#carousel-392499" class="right carousel-control">›</a>
      </div>




</div> <!-- /container -->
<?php require_once 'footer.php'; ?>
